/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package multiface.valentinorusso.jpa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego64
 */
@Entity
@Table(name = "file")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
    @NamedQuery(name = "File.findByIdfile", query = "SELECT f FROM File f WHERE f.idfile = :idfile"),
    @NamedQuery(name = "File.findByNome", query = "SELECT f FROM File f WHERE f.nome = :nome"),
    @NamedQuery(name = "File.findByDataora", query = "SELECT f FROM File f WHERE f.dataora = :dataora"),
    @NamedQuery(name = "File.findByDimensione", query = "SELECT f FROM File f WHERE f.dimensione = :dimensione"),
    @NamedQuery(name = "File.findByTipo", query = "SELECT f FROM File f WHERE f.tipo = :tipo"),
    @NamedQuery(name = "File.findByCopertina", query = "SELECT f FROM File f WHERE f.copertina = :copertina")})
public class File implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idfile")
    private Integer idfile;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @Basic(optional = false)
    @Column(name = "dataora")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataora;
    @Basic(optional = false)
    @Lob
    @Column(name = "bytes")
    private byte[] bytes;
    @Lob
    @Column(name = "bytes_th")
    private byte[] bytesTh;
    @Basic(optional = false)
    @Column(name = "dimensione")
    private int dimensione;
    @Basic(optional = false)
    @Column(name = "tipo")
    private String tipo;
    @Basic(optional = false)
    @Column(name = "copertina")
    private boolean copertina;
    @JoinColumn(name = "lavoro", referencedColumnName = "idlavoro")
    @ManyToOne(optional = false)
    private Lavoro lavoro;

    public File() {
    }

    public File(Integer idfile) {
        this.idfile = idfile;
    }

    public File(Integer idfile, String nome, Date dataora, byte[] bytes, int dimensione, String tipo, boolean copertina) {
        this.idfile = idfile;
        this.nome = nome;
        this.dataora = dataora;
        this.bytes = bytes;
        this.dimensione = dimensione;
        this.tipo = tipo;
        this.copertina = copertina;
    }

    public Integer getIdfile() {
        return idfile;
    }

    public void setIdfile(Integer idfile) {
        this.idfile = idfile;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Date getDataora() {
        return dataora;
    }

    public void setDataora(Date dataora) {
        this.dataora = dataora;
    }

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    public byte[] getBytesTh() {
        return bytesTh;
    }

    public void setBytesTh(byte[] bytesTh) {
        this.bytesTh = bytesTh;
    }

    public int getDimensione() {
        return dimensione;
    }

    public void setDimensione(int dimensione) {
        this.dimensione = dimensione;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public boolean getCopertina() {
        return copertina;
    }

    public void setCopertina(boolean copertina) {
        this.copertina = copertina;
    }

    public Lavoro getLavoro() {
        return lavoro;
    }

    public void setLavoro(Lavoro lavoro) {
        this.lavoro = lavoro;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idfile != null ? idfile.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof File)) {
            return false;
        }
        File other = (File) object;
        if ((this.idfile == null && other.idfile != null) || (this.idfile != null && !this.idfile.equals(other.idfile))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "multiface.valentinorusso.jpa.File[ idfile=" + idfile + " ]";
    }
    
}
